<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class RDoc::Generator::JsonIndex - rdoc: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-RDoc::Generator::JsonIndex-label-Index+Format">Index Format</a>
    <li><a href="#class-RDoc::Generator::JsonIndex-label-LICENSE">LICENSE</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../../Object.html">Object</a>
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="../Text.html">RDoc::Text</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-build_index">#build_index</a>
    <li ><a href="#method-i-class_dir">#class_dir</a>
    <li ><a href="#method-i-debug_msg">#debug_msg</a>
    <li ><a href="#method-i-file_dir">#file_dir</a>
    <li ><a href="#method-i-generate">#generate</a>
    <li ><a href="#method-i-generate_gzipped">#generate_gzipped</a>
    <li ><a href="#method-i-index_classes">#index_classes</a>
    <li ><a href="#method-i-index_methods">#index_methods</a>
    <li ><a href="#method-i-index_pages">#index_pages</a>
    <li ><a href="#method-i-search_string">#search_string</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-RDoc::Generator::JsonIndex">
    <h1 id="class-RDoc::Generator::JsonIndex" class="class">
      class RDoc::Generator::JsonIndex
    </h1>

    <section class="description">
    
<p>The <a href="JsonIndex.html"><code>JsonIndex</code></a> generator is designed to complement an HTML generator and produces a JSON search index.  This generator is derived from sdoc by Vladimir Kolesnikov and contains verbatim code written by him.</p>

<p>This generator is designed to be used with a regular HTML generator:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span><span class="ruby-operator">::</span><span class="ruby-constant">Darkfish</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span> <span class="ruby-identifier">options</span>
    <span class="ruby-comment"># ...</span>
    <span class="ruby-ivar">@base_dir</span> = <span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">pwd</span>.<span class="ruby-identifier">expand_path</span>

    <span class="ruby-ivar">@json_index</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span><span class="ruby-operator">::</span><span class="ruby-constant">JsonIndex</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">self</span>, <span class="ruby-identifier">options</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate</span>
    <span class="ruby-comment"># ...</span>
    <span class="ruby-ivar">@json_index</span>.<span class="ruby-identifier">generate</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>

<h2 id="class-RDoc::Generator::JsonIndex-label-Index+Format">Index Format<span><a href="#class-RDoc::Generator::JsonIndex-label-Index+Format">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>The index is output as a JSON file assigned to the global variable <code>search_data</code>.  The structure is:</p>

<pre>var search_data = {
  &quot;index&quot;: {
    &quot;searchIndex&quot;:
      [&quot;a&quot;, &quot;b&quot;, ...],
    &quot;longSearchIndex&quot;:
      [&quot;a&quot;, &quot;a::b&quot;, ...],
    &quot;info&quot;: [
      [&quot;A&quot;, &quot;A&quot;, &quot;A.html&quot;, &quot;&quot;, &quot;&quot;],
      [&quot;B&quot;, &quot;A::B&quot;, &quot;A::B.html&quot;, &quot;&quot;, &quot;&quot;],
      ...
    ]
  }
}</pre>

<p>The same item is described across the <code>searchIndex</code>, <code>longSearchIndex</code> and <code>info</code> fields.  The <code>searchIndex</code> field contains the item’s short name, the <code>longSearchIndex</code> field contains the full_name (when appropriate) and the <code>info</code> field contains the item’s name, full_name, path, parameters and a snippet of the item’s comment.</p>

<h2 id="class-RDoc::Generator::JsonIndex-label-LICENSE">LICENSE<span><a href="#class-RDoc::Generator::JsonIndex-label-LICENSE">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Copyright © 2009 Vladimir Kolesnikov</p>

<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>

<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>

<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="SEARCH_INDEX_FILE">SEARCH_INDEX_FILE
          <dd><p>Where the search index lives in the generated output</p>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(parent_generator, options)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new generator.  <code>parent_generator</code> is used to determine the <a href="JsonIndex.html#method-i-class_dir"><code>class_dir</code></a> and <a href="JsonIndex.html#method-i-file_dir"><code>file_dir</code></a> of links in the output index.</p>

<p><code>options</code> are the same options passed to the parent generator.</p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 94</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span> <span class="ruby-identifier">parent_generator</span>, <span class="ruby-identifier">options</span>
  <span class="ruby-ivar">@parent_generator</span> = <span class="ruby-identifier">parent_generator</span>
  <span class="ruby-ivar">@store</span>            = <span class="ruby-identifier">parent_generator</span>.<span class="ruby-identifier">store</span>
  <span class="ruby-ivar">@options</span>          = <span class="ruby-identifier">options</span>

  <span class="ruby-ivar">@template_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span> <span class="ruby-string">&#39;../template/json_index&#39;</span>, <span class="ruby-keyword">__FILE__</span>
  <span class="ruby-ivar">@base_dir</span> = <span class="ruby-ivar">@parent_generator</span>.<span class="ruby-identifier">base_dir</span>

  <span class="ruby-ivar">@classes</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@files</span>   = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@index</span>   = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-build_index" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_index</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds the JSON index as a Hash.</p>

                              <div class="method-source-code" id="build_index-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 110</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_index</span>
  <span class="ruby-identifier">reset</span> <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">all_files</span>.<span class="ruby-identifier">sort</span>, <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">all_classes_and_modules</span>.<span class="ruby-identifier">sort</span>

  <span class="ruby-identifier">index_classes</span>
  <span class="ruby-identifier">index_methods</span>
  <span class="ruby-identifier">index_pages</span>

  { <span class="ruby-value">:index</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-ivar">@index</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-class_dir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">class_dir</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The directory classes are written to</p>

                              <div class="method-source-code" id="class_dir-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 271</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">class_dir</span>
  <span class="ruby-ivar">@parent_generator</span>.<span class="ruby-identifier">class_dir</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-debug_msg" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug_msg</span><span
                                class="method-args">(*msg)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Output progress information if debugging is enabled</p>

                              <div class="method-source-code" id="debug_msg-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 123</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">debug_msg</span> <span class="ruby-operator">*</span><span class="ruby-identifier">msg</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">$DEBUG_RDOC</span>
  <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">msg</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-file_dir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">file_dir</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>The directory files are written to</p>

                              <div class="method-source-code" id="file_dir-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 278</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">file_dir</span>
  <span class="ruby-ivar">@parent_generator</span>.<span class="ruby-identifier">file_dir</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes the JSON index to disk</p>

                              <div class="method-source-code" id="generate-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 131</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate</span>
  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;Generating JSON index&quot;</span>

  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;  writing search index to %s&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-constant">SEARCH_INDEX_FILE</span>
  <span class="ruby-identifier">data</span> = <span class="ruby-identifier">build_index</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">dry_run</span>

  <span class="ruby-identifier">out_dir</span> = <span class="ruby-ivar">@base_dir</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">op_dir</span>
  <span class="ruby-identifier">index_file</span> = <span class="ruby-identifier">out_dir</span> <span class="ruby-operator">+</span> <span class="ruby-constant">SEARCH_INDEX_FILE</span>

  <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">index_file</span>.<span class="ruby-identifier">dirname</span>, <span class="ruby-value">:verbose</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">$DEBUG_RDOC</span>

  <span class="ruby-identifier">index_file</span>.<span class="ruby-identifier">open</span> <span class="ruby-string">&#39;w&#39;</span>, <span class="ruby-value">0644</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">io</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">io</span>.<span class="ruby-identifier">set_encoding</span> <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>
    <span class="ruby-identifier">io</span>.<span class="ruby-identifier">write</span> <span class="ruby-string">&#39;var search_data = &#39;</span>

    <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">dump</span> <span class="ruby-identifier">data</span>, <span class="ruby-identifier">io</span>, <span class="ruby-value">0</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;SOURCE_DATE_EPOCH&#39;</span>].<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">index_file</span>.<span class="ruby-identifier">utime</span> <span class="ruby-identifier">index_file</span>.<span class="ruby-identifier">atime</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-constant">ENV</span>[<span class="ruby-string">&#39;SOURCE_DATE_EPOCH&#39;</span>].<span class="ruby-identifier">to_i</span>).<span class="ruby-identifier">gmtime</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-ivar">@template_dir</span> <span class="ruby-keyword">do</span>
    <span class="ruby-constant">Dir</span>[<span class="ruby-string">&#39;**/*.js&#39;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">source</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">dest</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">out_dir</span>, <span class="ruby-identifier">source</span>

      <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">install</span> <span class="ruby-identifier">source</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0644</span>, <span class="ruby-value">:preserve</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:verbose</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">$DEBUG_RDOC</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate_gzipped" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate_gzipped</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Compress the search_index.js file using gzip</p>

                              <div class="method-source-code" id="generate_gzipped-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 166</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_gzipped</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">dry_run</span> <span class="ruby-keyword">or</span> <span class="ruby-keyword">not</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">Zlib</span>)

  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;Compressing generated JSON index&quot;</span>
  <span class="ruby-identifier">out_dir</span> = <span class="ruby-ivar">@base_dir</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">op_dir</span>

  <span class="ruby-identifier">search_index_file</span> = <span class="ruby-identifier">out_dir</span> <span class="ruby-operator">+</span> <span class="ruby-constant">SEARCH_INDEX_FILE</span>
  <span class="ruby-identifier">outfile</span>           = <span class="ruby-identifier">out_dir</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;#{search_index_file}.gz&quot;</span>

  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;Reading the JSON index file from %s&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">search_index_file</span>
  <span class="ruby-identifier">search_index</span> = <span class="ruby-identifier">search_index_file</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">mode:</span> <span class="ruby-string">&#39;r:utf-8&#39;</span>)

  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;Writing gzipped search index to %s&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">outfile</span>

  <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipWriter</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">outfile</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gz</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">mtime</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">search_index_file</span>)
    <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">orig_name</span> = <span class="ruby-identifier">search_index_file</span>.<span class="ruby-identifier">basename</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">search_index</span>
    <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">close</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># GZip the rest of the js files</span>
  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-ivar">@template_dir</span> <span class="ruby-keyword">do</span>
    <span class="ruby-constant">Dir</span>[<span class="ruby-string">&#39;**/*.js&#39;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">source</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">dest</span> = <span class="ruby-identifier">out_dir</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">source</span>
      <span class="ruby-identifier">outfile</span> = <span class="ruby-identifier">out_dir</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot;#{dest}.gz&quot;</span>

      <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;Reading the original js file from %s&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">dest</span>
      <span class="ruby-identifier">data</span> = <span class="ruby-identifier">dest</span>.<span class="ruby-identifier">read</span>

      <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;Writing gzipped file to %s&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">outfile</span>

      <span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipWriter</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">outfile</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">gz</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">mtime</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">dest</span>)
        <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">orig_name</span> = <span class="ruby-identifier">dest</span>.<span class="ruby-identifier">basename</span>.<span class="ruby-identifier">to_s</span>
        <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">data</span>
        <span class="ruby-identifier">gz</span>.<span class="ruby-identifier">close</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-index_classes" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">index_classes</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds classes and modules to the index</p>

                              <div class="method-source-code" id="index_classes-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 211</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">index_classes</span>
  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;  generating class search index&quot;</span>

  <span class="ruby-identifier">documented</span> = <span class="ruby-ivar">@classes</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">select</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">document_self_or_methods</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">documented</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">debug_msg</span> <span class="ruby-node">&quot;    #{klass.full_name}&quot;</span>
    <span class="ruby-identifier">record</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">search_record</span>
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:searchIndex</span>]     <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">search_string</span>(<span class="ruby-identifier">record</span>.<span class="ruby-identifier">shift</span>)
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:longSearchIndex</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">search_string</span>(<span class="ruby-identifier">record</span>.<span class="ruby-identifier">shift</span>)
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:info</span>]            <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">record</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-index_methods" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">index_methods</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds methods to the index</p>

                              <div class="method-source-code" id="index_methods-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 230</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">index_methods</span>
  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;  generating method search index&quot;</span>

  <span class="ruby-identifier">list</span> = <span class="ruby-ivar">@classes</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">flat_map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">method_list</span>
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">sort_by</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
    [<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">method</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">full_name</span>]
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">debug_msg</span> <span class="ruby-node">&quot;    #{method.full_name}&quot;</span>
    <span class="ruby-identifier">record</span> = <span class="ruby-identifier">method</span>.<span class="ruby-identifier">search_record</span>
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:searchIndex</span>]     <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{search_string record.shift}()&quot;</span>
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:longSearchIndex</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{search_string record.shift}()&quot;</span>
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:info</span>]            <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">record</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-index_pages" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">index_pages</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adds pages to the index</p>

                              <div class="method-source-code" id="index_pages-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 251</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">index_pages</span>
  <span class="ruby-identifier">debug_msg</span> <span class="ruby-string">&quot;  generating pages search index&quot;</span>

  <span class="ruby-identifier">pages</span> = <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">select</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">file</span>.<span class="ruby-identifier">text?</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">pages</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">debug_msg</span> <span class="ruby-node">&quot;    #{page.page_name}&quot;</span>
    <span class="ruby-identifier">record</span> = <span class="ruby-identifier">page</span>.<span class="ruby-identifier">search_record</span>
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:searchIndex</span>]     <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">search_string</span>(<span class="ruby-identifier">record</span>.<span class="ruby-identifier">shift</span>)
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:longSearchIndex</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;&#39;</span>
    <span class="ruby-identifier">record</span>.<span class="ruby-identifier">shift</span>
    <span class="ruby-ivar">@index</span>[<span class="ruby-value">:info</span>]            <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">record</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-search_string" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">search_string</span><span
                                class="method-args">(string)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes whitespace and downcases <code>string</code></p>

                              <div class="method-source-code" id="search_string-source">
            <pre><span class="ruby-comment"># File rdoc/generator/json_index.rb, line 296</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">search_string</span> <span class="ruby-identifier">string</span>
  <span class="ruby-identifier">string</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\s/</span>, <span class="ruby-string">&#39;&#39;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

